home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / fp / ifp_unix.lzh / ifp / interp / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-05-23  |  4.9 KB  |  189 lines

  1.  
  2. /****** main.c ********************************************************/
  3. /**                                                                  **/
  4. /**                    University of Illinois                        **/
  5. /**                                                                  **/
  6. /**                Department of Computer Science                    **/
  7. /**                                                                  **/
  8. /**   Tool: IFP                         Version: 0.6                 **/
  9. /**                                                                  **/
  10. /**   Author:  Arch D. Robison          Date:   May 1, 1985          **/
  11. /**                                                                  **/
  12. /**   Revised by: Arch D. Robison       Date:  May 23, 1989          **/
  13. /**                                                                  **/
  14. /**   Principal Investigators: Prof. R. H. Campbell                  **/
  15. /**                            Prof. W. J. Kubitz                    **/
  16. /**                                                                  **/
  17. /**                                                                  **/
  18. /**------------------------------------------------------------------**/
  19. /**   (C) Copyright 1989  University of Illinois Board of Trustees   **/
  20. /**                       All Rights Reserved.                       **/
  21. /**********************************************************************/
  22.  
  23. #include <stdio.h>
  24. #include "struct.h"
  25. #include "node.h"
  26. #include "umax.h"
  27. #include "cache.h"
  28. #include "stats.h"
  29.  
  30. #if OPSYS!=CTSS
  31. #endif
  32.  
  33. static char Version[] = "\nIllinois FP 0.6";
  34. static char Author [] = " Arch D. Robison";
  35. static char Date   [] = " Dec 5, 1986\n";
  36.  
  37. #if OPSYS==UNIX
  38. #define OPSYSTEM "UNIX"
  39. #endif
  40. #if OPSYS==MSDOS
  41. #define OPSYSTEM "MS-DOS"
  42. #endif
  43. #if OPSYS==CTSS
  44. #define OPSYSTEM "CTSS"
  45. #endif
  46. #if OPSYS==APPLE
  47. #define OPSYSTEM "Macintosh"
  48. #endif
  49.  
  50. boolean LongPathFlag = 0;
  51.  
  52. #ifdef COMPILE
  53. boolean CompilerFlag = 0;       /* Enable compiler if set */
  54. boolean RuleFlag = 0;           /* Display rules if set   */
  55. #endif
  56.  
  57. private void Init ()
  58.    {
  59.       /* 
  60.        * Not all the D_* functions exist in a given IFP implementation 
  61.        */
  62.       extern void D_arith (), D_class (), D_form (), D_pred (), 
  63.           D_misc (), D_seq (), D_ss (), D_subseq (), 
  64.           D_string (), D_cray (), D_vector ();
  65.  
  66.       extern void InitFile ();
  67.       extern char RootPath[];                /* from file.c */
  68. #if OPSYS==MSDOS
  69.       char CWD [64];
  70. #endif
  71. #if OPSYS==UNIX
  72.       extern void EnvGet ();                /* from file.c */
  73. #endif    
  74.       if (Debug & DebugInit) printf ("enter Init\n");
  75.  
  76.       {extern void InitString(); InitString();}        /* from string.c */
  77. #if OPSYS==MSDOS
  78.       CWDGet (CWD,MAXPATH);
  79. #endif
  80. #if OPSYS==UNIX
  81.       EnvGet ("IFProot",RootPath,MAXPATH);          /* Check for RootPath */
  82. #endif /* OPSYS == UNIX */
  83. #if ECACHE
  84.       InitCache ();
  85. #endif
  86.       {extern void InitNode (); InitNode ();}
  87.       D_arith ();
  88.       D_form ();
  89.       D_pred ();
  90.       D_seq ();
  91.       D_subseq ();
  92.       D_misc ();
  93.       D_ss ();
  94.       D_string ();
  95. #if OPSYS==MSDOS
  96.       InitFile (CWD);
  97. #endif
  98. #if OPSYS==UNIX || OPSYS==CTSS
  99.       InitFile ();
  100. #endif
  101. #ifdef COMPILE
  102.       if (CompilerFlag) {
  103.      extern void InitSymTab (), InitCompiler ();
  104.      InitSymTab ();
  105.      InitCompiler ();
  106.       }
  107. #endif
  108. #ifdef GRAPHICS
  109.       InitDraw (); /* for CS9000 graphics only */
  110. #endif
  111. #if STATS
  112.       printf (" (stats)");
  113. #endif
  114.       if (Debug & DebugInit) printf ("exit Init\n");
  115.    }
  116.  
  117. extern void UserLoop ();
  118.  
  119. /*
  120.  * GetOptions
  121.  *
  122.  * Process command line options.
  123.  *
  124.  * Input
  125.  *     argv = command line arguments
  126.  *    argc = argument count
  127.  */
  128. private void GetOptions (argc,argv)
  129.    int argc;
  130.    char *argv[];
  131.    {
  132.       int k;
  133.       char *P;
  134.  
  135.       for (k=1; k<argc; k++) 
  136.      if (*(P=argv[k]) == '-') 
  137.         while (*P && *++P)
  138.            switch (*P) {
  139. #ifdef COMPILE
  140.           case 'c': CompilerFlag = 1; break;
  141.           case 'r': RuleFlag = 1; break;
  142. #endif 
  143. #if DEBUG
  144.           case 'd': 
  145.              while (*++P) {
  146.                 extern char *index();
  147.             static char Opt[] = DebugOpt;
  148.                 char *t = index (Opt,*P);
  149.             if (t != NULL) Debug |= 1 << (t-Opt);
  150.             else printf ("[unknown option = -d%c] ",*P);
  151.              }
  152.              break; 
  153. #endif /* DEBUG */
  154. #if ECACHE
  155.           case 'e':
  156.              while (*++P)
  157.             if (*P >= '0' && *P <= '2')
  158.                Cache[*P-'0'].Enable = 1;
  159.             else
  160.                printf ("[unknown -e option = %c] ",*P);
  161.              break;
  162. #endif /* ECACHE */
  163.           case 'l': LongPathFlag = 1; break;
  164.           default: 
  165.              printf ("[unknown option = %c] ",*P);
  166.              P = "";
  167.              break;
  168.            }
  169.    }
  170.  
  171.  
  172. main (argc, argv)
  173.    int argc;
  174.    char *argv[];
  175.    {
  176.       printf ("%s: (%s)",Version,OPSYSTEM);
  177.       (void) fflush (stdout);
  178.       GetOptions (argc,argv);
  179.       Init ();
  180.       printf ("\n\n");
  181.       UserLoop ();
  182.       Terminate();
  183.       if (Debug & DebugInit) printf ("normal exit\n");
  184.       exit (0);
  185.    }
  186.  
  187. /************************** end of main.c **************************/
  188.  
  189.